#include "../status_task.h"
#include "../../driver/analog.h"
#include "../../driver/heat/ntc_sensor.h"
#include "../../driver/heat/parts.h"
#include "../../driver/heat/sensor.h"
#include "../../service/salve_conn.h"
#include "./draw_task.h"
#include "./heat_task.h"

namespace task {

using namespace driver;
using namespace service;

constexpr uint16_t APP_VERSION = 0x02;

void StatusTask::run() {

    for (;;) {
        ntcSensor->read_all();

        uint16_t sw = sensor->status() |
            (ntcSensor->is_water_ok() << 11) |
            (ntcSensor->is_steam_ok() << 12);

        salveConn->status_notify(
            APP_VERSION,
            sw,
            analog->change_value(),
            sensor->flow_count(),
            parts->status(),
            ntcSensor->water_temp(),
            ntcSensor->steam_temp(),
            drawTask->state(),
            heatTask->state()
        );

        osDelay(500);
    }
}


}
